/*
 * @Author: your name
 * @Date: 2021-08-13 17:28:12
 * @LastEditTime: 2021-10-08 10:21:21
 * @LastEditors: by
 * @Description: In User Settings Edit
 * @FilePath: \yyzxwebd:\hsx\水文局设备运行维护管理平台\web\src\utils\mixins.js
 */


// 计算表格高度
// 1.表格固定class el_table
// 2.分页固定class el_footer

export default {
  data() {
    return {
      height:100,
    }
  },
  mounted() {
    this.getHeight()
  },
  watch:{
      windowWidth(){
          this.getHeight()
      },
      windowHeight(){
        this.getHeight()
    }
  },
  computed: {
    windowWidth() {
        return this.$store.state.local.windowWidth
    },
    windowHeight() {
        return this.$store.state.local.windowHeight
    }
  },
  methods: {
    getHeight(){//获取表格高度
      this.$nextTick(()=>{
        var footerH = 0
        if(document.getElementsByClassName('el_footer') && document.getElementsByClassName('el_footer')[0]){
          footerH = document.getElementsByClassName('el_footer')[0].clientHeight
        }
        var tableTop = 0
        if(document.getElementsByClassName('el_table') && document.getElementsByClassName('el_table')[0]){
          tableTop = document.getElementsByClassName('el_table')[0].offsetTop + 70 //表格距离顶部的距离
        }
        this.height =  (this.windowHeight -footerH - tableTop) +'px'
      })
    },
    tableRowClass(row) {//表格斑马样式
        if(row.rowIndex%2 == 0) {
          return 'even'
        }else {
          return 'odd'
      }
    },
  }
}
